<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="menu" content="superviseMenu" />
<meta name="nav" content="2" />
<meta name="acc" content="0" />
<title>中间交工验收检测信息</title>
<script type="text/javascript" charset="utf-8"
	src="<c:url value='/KindEditor/kindeditor.js'/>"></script>
<script type="text/javascript">
	function getcheckResult() {
		var date = new Date();
		$.get("${ctx}/business/mdetect/issue!listall.action?cid=${id}&decorator=open&update=true&confirm=true&time="
								+ date, function(data) {
							$("#frame").html(data);
		});
	}

	var i = 1;
	function addFile(divName, fileName) {
		var dv = document.getElementById(divName);

		var file = document.createElement("input");
		file.type = "file";
		file.name = fileName;
		file.id = fileName + i;
		dv.appendChild(file);

		var btn = document.createElement("input");
		btn.type = "button";
		btn.id = btn.name = "btn" + i;
		btn.value = "删除";

		btn.onclick = function() {
			var b = document.getElementById(btn.id);
			dv.removeChild(b.nextSibling);
			dv.removeChild(b.previousSibling);
			dv.removeChild(b);
		}

		dv.appendChild(btn);
		dv.appendChild(document.createElement("BR"));

		i++;
	}

	KE.show({
		id : 'content',
		cssPath : './index.css',
		afterCreate : function(id) {
			KE.event.ctrl(document, 13, function() {
				KE.sync(id);
				document.forms['inputForm'].submit();
			});
			KE.event.ctrl(KE.g[id].iframeDoc, 13, function() {
				KE.sync(id);
				document.forms['inputForm'].submit();
			});
		}
	});

	$(document).ready(function() {
		$("#flowCode").focus();
		$("#inputForm").validate({
			event : "blur",
			isTip : true
		});

		getcheckResult();
		
		$("#dealDate").addClass("Wate").bind("click", function() {
			WdatePicker({
				skin : 'whyGreen',
				dateFmt : 'yyyy-MM-dd'
			});
		});
		
		$("#reportDate").addClass("Wate").bind("click", function() {
			WdatePicker({
				skin : 'whyGreen',
				dateFmt : 'yyyy-MM-dd'
			});
		});

		$("#save").click(function() {
			var projectId = $("input[name='projectId']").val();
			var cid = $("input[name='cid']").val();
			var dealDate = $("input[name='dealDate']").val();
			var content = $("textarea[name='content1']").val();
			var dealContent = $("textarea[name='dealContent']").val();
			var type = $("select[name='type1']").val();
			var remark = $("textarea[name='remark1']").val();
			$.post("${ctx}/business/mdetect/issue!save.action", {
				projId : projectId,
				content : content,
				dealContent : dealContent,
				dealDate : dealDate,
				type : type,
				remark : remark,
				cid : cid
			}, function(data) {
				getcheckResult();
			});
		});
	});
	function updateProblem(id){
		var titleName = '问题修改';
		var url = appConfig.contPath+"/business/mdetect/issue!input.action?id="+id;
	 	showWindow(titleName,url,{width:740,height:350});
	}
	
	function close(){
		 $.window.closeAll(); 
	}

</script>
</head>
<body>
	<form
		action="${ctx}/business/mdetect/report!save.action?projectId=${projId}"
		class="yform" method="post" id="inputForm"
		enctype="multipart/form-data">
		<input type="hidden" name="id" id="id" value="${id }"> <input
			type="hidden" name="fid" id="fid" value="${middleDatection.id }">
		<input type="hidden" name="cid" id="cid" value="${id }"> <input
			type="hidden" name="projectId" id="projectId" value="${projId }">
		<div id="caption">
			<h6>${licenseplateNumber}中间交工检测情况汇报</h6>
		</div>
		<div>
			<fieldset>
				<legend>中间交工验收检测意见</legend>
				<table class="noborder">
					<tr class="type-text">
						<td>收文单位</td>
						<td><input type="text" name="orgName" id="orgName"
							value="${orgName }">
						</td>
					</tr>
					<tr class="type-text">
						<td>抄送单位</td>
						<td><input type="text" name="cc" id="cc" value="${cc }">
						</td>
					</tr>
					<tr class="type-text">
						<td>报告出具时间</td>
						<td><input type="text" id="reportDate" name="reportDate"
							value='<fmt:formatDate value="${reportDate }" pattern="yyyy-MM-dd"/>'>
						</td>
					</tr>
					<tr class="type-text">
						<td>报告关键内容</td>
						<td><textarea name="content" id="content">${content }</textarea>
						</td>
					</tr>
					<tr class="type-text">
						<td>备注</td>
						<td><textarea name="remark" id="remark">${remark }</textarea>
						</td>
					</tr>
					<tr class="type-text">
						<td><input type="button" value="添加上传"
							onclick="addFile('sources','upload')"></td>
						<td id="sources"></td>
					</tr>
				</table>
				<c:if test="${not empty attachments }">
					<div id="caption">
						<h6>${licenseplateNumber}已有附件</h6>
					</div>
					<table>
						<c:forEach items="${attachments }" var="attachment"
							varStatus="state">
							<tr id="tr${state.index }">
								<td colspan="4"><a title="下载"
									href="${ctx}/servlet/annex?id=${attachment.id}">${attachment.upfileFileName}(${attachment.type})<fmt:formatDate
											value="${attachment.fileTime}" pattern="yyyy-MM-dd" /> </a> <span
									onclick="deleteAttachmentById('${attachment.id}','tr${state.index }')"
									class="delete" title="删除附件"></span></td>
							</tr>
						</c:forEach>
					</table>
				</c:if>
			</fieldset>
			<fieldset>
				<legend>中间交工验收存在问题</legend>
				<table class="noborder">
					<tr class="type-text">
						<td>工程名称</td>
						<td colspan="3"><input type="text" readonly="readonly"
							value='<pt:labels type="proj" argument1="${projId}" single="true"></pt:labels>'>
						</td>
					</tr>
					<tr class="type-text">
						<td>问题类型</td>
						<td><pt:code category="3011" name="type1"></pt:code>
						</td>
						<td>处理时间</td>
						<td><input type="text" name="dealDate" id="dealDate">
						</td>
					</tr>
					<tr class="type-text">
						<td>概要描述</td>
						<td colspan="3"><textarea name="content1" id="content1"></textarea></td>
					</tr>
					<tr class="type-text">
						<td>处理措施</td>
						<td colspan="3"><textarea name="dealContent" id="dealContent"></textarea>
						</td>
					</tr>
					<tr class="type-text">
						<td>备注</td>
						<td colspan="3"><textarea name="remark1" id="remark1"></textarea></td>
					</tr>
					<tr class="type-text">
						<td colspan="4" align="center"><div class="type-button">
								<input type="button" value="添加" id="save" name="save">
							</div></td>
					</tr>
				</table>
			</fieldset>
			<fieldset>
				<legend>中间交工验收问题情况汇报列表</legend>
				<div id="frame"></div>
			</fieldset>
		</div>
		<div class="type-button">
			<input type="submit" class="submit" value="下一步" /> <input
				type="button" value="返回" class="reset" onclick="history.back()" />
		</div>
	</form>
</body>
</html>